﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing.plaf.basic.background {
    import flash.display.*;
    import flash.geom.*;
    import org.aswing.*;
    import flash.filters.*;
    import org.aswing.geom.*;
    import org.aswing.plaf.*;
    import org.aswing.graphics.*;
    import org.aswing.plaf.basic.*;

    public class ToggleButtonBackground implements GroundDecorator, UIResource {

        protected var shape:Shape;

        public function ToggleButtonBackground(){
            this.shape = new Shape();
        }
        public function updateDecorator(_arg1:Component, _arg2:Graphics2D, _arg3:IntRectangle):void{
            var _local6:StyleResult;
            var _local8:ButtonModel;
            var _local9:Boolean;
            var _local10:Number;
            var _local11:IntRectangle;
            var _local12:Matrix;
            var _local13:Number;
            var _local14:Boolean;
            var _local4:AbstractButton = (_arg1 as AbstractButton);
            if (_local4 == null){
                return;
            };
            this.shape.graphics.clear();
            _arg2 = new Graphics2D(this.shape.graphics);
            _arg3 = _arg3.clone();
            _arg3.width = (_arg3.width - 2);
            _arg3.height = (_arg3.height - 2);
            var _local5:ASColor = _arg1.getBackground();
            var _local7:StyleTune = _arg1.getStyleTune();
            if (_arg1.isOpaque()){
                _local8 = _local4.getModel();
                _local9 = ((_local8.isArmed()) || (_local8.isSelected()));
                _local10 = 1;
                _local11 = _arg3.clone();
                _local12 = new Matrix();
                _local13 = (Math.PI / 2);
                _local14 = false;
                if (_local9){
                    if (!_local4.isEnabled()){
                        _local5 = _local5.offsetHLS(0, 0.2, -0.06);
                        _local7 = _local7.sharpen(0.4);
                        _local10 = 2;
                    } else {
                        if (_local8.isRollOver()){
                            _local5 = _local5.offsetHLS(0, 0.025, 0);
                        };
                    };
                    _arg3.width = (_arg3.width + _local4.getShiftOffset());
                    _arg3.height = (_arg3.height + _local4.getShiftOffset());
                    _local10 = (_local10 * 2.5);
                    _local13 = (-(Math.PI) / 2);
                } else {
                    if (!_local4.isEnabled()){
                        _local5 = _local5.offsetHLS(0, 0.2, -0.06);
                        _local7 = _local7.sharpen(0.4);
                    } else {
                        if (_local8.isRollOver()){
                            _local5 = _local5.offsetHLS(0, 0.06, 0);
                        };
                    };
                };
                _local6 = new StyleResult(_local5, _local7);
                BasicGraphicsUtils.fillGradientRoundRect(_arg2, _arg3, _local6, _local13);
                _local12.createGradientBox(_local11.width, _local11.height, (Math.PI / 2), _local11.x, _local11.y);
                _arg2.beginFill(new GradientBrush(GradientType.LINEAR, [_local6.bdark.getRGB(), _local6.bdark.getRGB()], [1, 0.6], [0, 0xFF], _local12));
                BasicGraphicsUtils.drawRoundRectLine(_arg2, _local11.x, _local11.y, _local11.width, _local11.height, _local6.round, 1);
                _arg2.endFill();
                _local12.createGradientBox(_local11.width, _local11.height, (Math.PI / 6), _local11.x, _local11.y);
                _arg2.beginFill(new GradientBrush(GradientType.LINEAR, [_local6.blight.getRGB(), _local6.blight.getRGB()], [1, 0.5], [0, 0xFF], _local12));
                _local11.grow(-1, -1);
                BasicGraphicsUtils.drawRoundRectLine(_arg2, _local11.x, _local11.y, _local11.width, _local11.height, (_local6.round - 1), 1);
                _arg2.endFill();
                this.shape.filters = [new DropShadowFilter((_local9) ? 2 : 1, 45, 0, (_local6.shadow * _local10), 2, 2, 1, 1, _local9)];
            };
        }
        public function getDisplay(_arg1:Component):DisplayObject{
            return (this.shape);
        }

    }
}//package org.aswing.plaf.basic.background 
